﻿using System;
using System.Net;
using System.ServiceModel.Web;

namespace suanpan.API.Components.Exceptions
{
    public class AuthenticationException : RESTException
    {
        public AuthenticationException(Exception ex)
            : base(ex, HttpStatusCode.Unauthorized, string.Format("Authentication failed. {0}",ex.Message))
        {
            
        }
        public AuthenticationException(string statusDescription):
            base(new Exception(statusDescription), HttpStatusCode.Unauthorized, statusDescription)
        {

        }
        public override void SetResponse()
        {
            base.SetResponse();
            WebOperationContext.Current.OutgoingResponse.Headers[HttpResponseHeader.WwwAuthenticate] = "Please Use Authentication Token";
        }
    }
}
